/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package group2assignone.ucm.manager;

import group2assignone.dao.MyDAO;
import group2assignone.model.Flight;
import group2assignone.ucm.UCController;
import group2assignone.ucm.UCStartup;
import group2assignone.view.manager.AddPromotionView;
import group2assignone.view.manager.ManagerView;

/**
 * Use Case: Confirm add new airport                         <br>
 * Pre-condition: User clicks save from add promotion view        .<br>
 * Post-condition: Manager Main view is displayed                           <br>
 * 1. system exits the current view                                         <br>
 * 2. System etrieves the new promotion data                                  <br>
 * 3. System writes the data to the database                                <br>
 * 4. System restors Manager Main VIew                                      <br>

 * @author group2
 */
public class UCAddPromotionSave implements UCController {

    private AddPromotionView promoView = new AddPromotionView();
    private Flight f;// = new Flight();

    /**
     * sets view and flight
     * @param eView
     * @param flight
     */
    public UCAddPromotionSave(AddPromotionView eView, Flight flight) {
        promoView = eView;
        f = flight;

    }

    @Override
    public void run() {
        //1. system exits the current view
        promoView.dispose();
        //2. System etrieves the new promotion data
        f = promoView.LoadDetails();
        //3. System writes the data to the database
        MyDAO coms = UCStartup.getInstance().getDAO();
        coms.sQLAddPromotion(f);
        // 4. System restors Manager Main VIew
        ManagerView mv = ManagerView.getInstance();
        mv.go();
    }
}
